﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TEL.TelPhoneF.Controls
{
    public partial class ButtonNumber : Button
    {
        public ButtonNumber()
        {
            InitializeComponent();
        }

        public ButtonNumber(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        private byte m_id;
        public byte ID
        {
            get { return m_id; }
            set { m_id = value; }
        }

        private char m_cap;
        public char Cap
        {
            get { return m_cap; }
            set { m_cap = value; }
        }

        private string[] m_latList;
        public string[] LatList
        {
            get { return m_latList; }
            set
            {
                m_latList = value;
                //  Text = CaptionStr;
            }
        }

        private string[] m_rusList;
        public string[] RusList
        {
            get { return m_rusList; }
            set
            {
                m_rusList = value;
                //  Text = CaptionStr;
            }
        }

        public string RegexStr
        {
            get
            {
                string res = ID.ToString();
                if (m_latList != null) res = m_latList.Aggregate(res, (current, item) => current + string.Format("|{0}", item));
                if (m_rusList != null) res = m_rusList.Aggregate(res, (current, item) => current + string.Format("|{0}", item));
                return res;
            }
        }

        public string CaptionStr
        {
            get
            {
                try
                {
                    string res = ID.ToString();
                    if (m_latList != null) res = " " + m_latList.Aggregate(res, (current, item) => current + string.Format("{0}", item));
                    if (m_rusList != null) res = " " + m_rusList.Aggregate(res, (current, item) => current + string.Format("{0}", item));
                    return res;
                }
                catch (Exception)
                {
                    return ((byte)Tag).ToString();
                }

            }
        }

        private bool m_Enter = false;
        private bool m_Down = false;


        private void ButtonNumber_Paint(object sender, PaintEventArgs e)
        {
            if (m_Down)
            {
                Brush b = new SolidBrush(Color.FromArgb(64, Form1.BlueSkinColor));
                Rectangle rectangle = new Rectangle(new Point(0, 0), this.Size);
                e.Graphics.FillRectangle(b, rectangle);

            }

            else if (m_Enter)
            {
                Brush b = new SolidBrush(Color.FromArgb(36, Form1.BlueSkinColor));
                Rectangle rectangle = new Rectangle(new Point(0, 0), this.Size);
                e.Graphics.FillRectangle(b, rectangle);
            }
        }

        private void ButtonNumber_MouseLeave(object sender, EventArgs e)
        {
                m_Enter = false;
        }

        private void ButtonNumber_MouseEnter(object sender, EventArgs e)
        {
                m_Enter = true;
        }

        private void ButtonNumber_MouseDown(object sender, MouseEventArgs e)
        {
            m_Down = true;
        }

        private void ButtonNumber_MouseUp(object sender, MouseEventArgs e)
        {
            m_Down = false;
            this.Invalidate();
        }

      
    }
}
